package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.common.CurrencyType;
import com.shrct.businessprocess.common.impl.CurrencyTypeImpl;
import com.shrct.businessprocess.project.RCExchangeRate;
import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.project.impl.RCProjectImpl;
import com.shrct.businessprocess.project.proxy.RCExchangeRateProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCEXCHANGERATE_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcexchangerate")
public class RCExchangeRateImpl extends BaseModelObject implements RCExchangeRate {
  public RCExchangeRateImpl() {
    super();
  }
  
  public RCExchangeRateImpl(final RCProject project) {
    super();
    this.project = project;
  }
  
  @JoinColumn(name = "project_id")
  @ManyToOne(targetEntity = RCProjectImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProject project;
  
  public RCProject getProject() {
    return this.project;
  }
  
  public RCExchangeRate setProject(final RCProject project) {
    this.project = project;
    return this;			
    
  }
  
  @JoinColumn(name = "currencyType_id")
  @ManyToOne(targetEntity = CurrencyTypeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private CurrencyType currencyType;
  
  public CurrencyType getCurrencyType() {
    return this.currencyType;
  }
  
  public RCExchangeRate setCurrencyType(final CurrencyType currencyType) {
    this.currencyType = currencyType;
    return this;			
    
  }
  
  private Double rate;
  
  public Double getRate() {
    return this.rate;
  }
  
  public RCExchangeRate setRate(final Double rate) {
    this.rate = rate;
    return this;			
    
  }
  
  public String getEntityName() {
    String _entityName = this.currencyType.getEntityName();
    String _plus = (_entityName + "[");
    String _string = this.rate.toString();
    String _plus_1 = (_plus + _string);
    String _plus_2 = (_plus_1 + "]");
    return _plus_2;
  }
  
  public static RCExchangeRate create(final RCProject project, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCExchangeRate rCExchangeRate = new com.shrct.businessprocess.project.impl.RCExchangeRateImpl(
    	project
    );
    objectFactory.create(rCExchangeRate);
    return rCExchangeRate;			
    
  }
  
  public static RCExchangeRate createRCExchangeRateImpl(final RCProject project, final IObjectFactory objectFactory, final Procedure1<RCExchangeRate> init) {
    com.shrct.businessprocess.project.RCExchangeRate rCExchangeRate = new com.shrct.businessprocess.project.impl.RCExchangeRateImpl(
    	project
    );
    objectFactory.create(rCExchangeRate);
    init.apply(rCExchangeRate);
    
    return rCExchangeRate;			
    
  }
  
  public RCExchangeRateProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCExchangeRateProxy proxy = new com.shrct.businessprocess.project.proxy.RCExchangeRateProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
